def f(g, s):
    g.sort()
    s.sort()
    left = 0
    n = len(g)
    right = 0
    m = len(s)
    ans = 0
    while left < n and right < m:
        if g[left] <= s[right]:
            ans += 1
            left += 1
            right += 1
        else:
            right += 1
    return ans


g = [1, 2, 3]
s = [1, 1]
print(f(g, s))

g = [1, 2]
s = [1, 2, 3]
print(f(g, s))
